package com.tanhua.server.controller;

import com.tanhua.server.service.BaiduService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author Xiao
 * @version 1.0
 * @description 百度Controller
 * @date 2021/10/31
 */
@RestController
@RequestMapping("/baidu")
public class BaiduController {
    @Autowired
    private BaiduService baiduService;

    /**
     * 百度-上报地理信息
     * @param map --> latitude(纬度)、longitude(经度)
     * @return
     */
    @PostMapping("/location")
    public ResponseEntity location(@RequestBody Map map) {
        Double latitude = Double.valueOf(map.get("latitude").toString());
        Double longitude = Double.valueOf(map.get("longitude").toString());
        String addrStr = map.get("addrStr").toString();
        baiduService.location(latitude, longitude, addrStr);
        return ResponseEntity.ok("位置已同步");
    }
}
